package com.gzx.plugin.tjzy.modular.call.api.controller;

import com.gzx.plugin.tjzy.modular.call.api.service.GzxHtCallApiService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import vip.xiaonuo.common.pojo.CommonResult;

/**
 * @author zjt
 * @description
 * @since 2025/3/27 18:37
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/tjzy/call/api")
public class GzxHtCallApiController {

    private final GzxHtCallApiService htCallApiService;

    /**
     * 根据CallId保存当前登录者信息
     *
     * @param callId
     * @return
     */
    @GetMapping("/setCallUser/{callId}")
    public CommonResult<Void> setCallUser(@PathVariable("callId") String callId) {
        htCallApiService.setCallUser(callId);
        return CommonResult.ok();
    }

    /**
     * 订阅语音文字消息
     *
     * @return
     */
    @GetMapping("/listen/start/{agentExtNo}")
    public CommonResult<Void> startListen(@PathVariable String agentExtNo) {
        htCallApiService.startListen(agentExtNo);
        return CommonResult.ok();
    }

    /**
     * 取消订阅语音文字消息
     *
     * @return
     */
    @GetMapping("/listen/stop/{agentExtNo}")
    public CommonResult<Void> stopListen(@PathVariable String agentExtNo) {
        htCallApiService.stopListen(agentExtNo);
        return CommonResult.ok();
    }

    /**
     * 获取当前登录用户的恒天账号
     *
     * @return
     */
    @GetMapping("/setCallNumber/{callNumber}")
    public CommonResult<Void> setCallNumber(@PathVariable String callNumber) {
        htCallApiService.setCallNumber(callNumber);
        return CommonResult.ok();
    }

    /**
     * 获取当前登录用户的恒天账号
     *
     * @return
     */
    @GetMapping("/getCallNumber")
    public CommonResult<String> getCallNumber() {
        return CommonResult.data(htCallApiService.getCallNumber());
    }

}
